

	//数字判定
	function chkPrice(obj){ 
		obj.value = obj.value.replace(/[^\d.]/g,""); 
		 
		obj.value = obj.value.replace(/^\./g,""); 
		
		obj.value = obj.value.replace(/\.{2,}/g,".");
		
		obj.value = obj.value.replace(/\.\d{3}/g,obj.value.substring(obj.value.indexOf("."),obj.value.length-1));
		
		obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$","."); 
	} 
	
	//过滤中文和特殊字符
	function chkChinese(obj){
		obj.value = obj.value.replace(/[\/\\?*:"|<>]/g,"");
		obj.value = obj.value.replace(/[\u4E00-\u9FA5]/g,"");
		
	}
	
	//去除空格
	function moveSpace(obj){
		obj.value = $.trim(obj.value);
	}
	
	//正整数
	function chkInt(obj){
		obj.value = obj.value.replace(/[^\d]/g,""); 
		
		obj.value = obj.value.replace(/^[0]/g,""); 
								
		obj.value = obj.value.replace(/^\d{0,3}/g,obj.value.substring(0,2));
		
		obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
		if(obj.value>31){
			obj.value = obj.value.replace(/\d/g,"");
		}
	}
	
	//正整数
	function checkIntDate(obj){
		obj.value = obj.value.replace(/[^\d]/g,""); 
		
		obj.value = obj.value.replace(/^[0]/g,""); 
								
		obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
	}
	
	//特殊字符判定
	function chkLast(obj){ 
		
		if(obj.value.substr((obj.value.length - 1), 1) == '.') 
		obj.value = obj.value.substr(0,(obj.value.length - 1)); 
	}
	//字数限制
	function checkInputLength(obj) {
		var maxChars = 40;
		if(obj.value){
			if (obj.value.length > maxChars)
				obj.value = obj.value.substring(0,maxChars);
			var curr = maxChars - obj.value.length;
			var id=obj.name;
			
			$("span[id='"+id+"']").text(curr);
		}
	}
	
	//检查必填字段  
	//(校验必填项不能为空(包括input框，单选框，复选框,文本域))  
	var elem = document.getElementById("age");  
	function checkRequired(elem){  
	        var name = elem.name;  
	        if(elem.type == "checkbox" || elem.type == "radio"){  
	            var results=[];  
	            results.numChecked = 0;  
	            var input = $("input");  
	            for(var i=0;i<input.length;i++){  
	                if(input[i].name == name){  
	                    results.push(input[i]);  
	                    if(input[i].checked){  
	                        results.numChecked++;  
	                    }  
	                }  
	            }  
	            return results.numChecked;  
	          
	        }else{   
	            return elem.value.length > 0 && elem.value != elem.defaultValue;  
	        }  
	    }
	//检查输入元素是否键入了信息的通用函数  
	function checkRequired(elem){  
	    if(elem.type == "checkbox" || elem.type == "radio")  
	        return getInputsByName(elem.name).numChecked;  
	    else   
	        return elem.value.length > 0 && elem.value != elem.defaultValue;  
	}  
	//找出指定name的所有input元素（对查找 以及处理复选框或单选框十分有用）  
	function getInputsByName(name){  
	    var results=[];  
	    results.numChecked = 0;  
	    var input = $("input");  
	    for(var i=0;i<input.length;i++){  
	        if(input[i].name == name){  
	            results.push(input[i]);  
	            if(input[i].checked){  
	                results.numChecked++;  
	            }
	        }
	    }
	    return results;  
	}
	  
	window.onload = function(){  
	    $("form")[0].onsubmit=function(){  
	        var elem = document.getElementById("age");  
	        if(!checkRequired(elem)){  
	            alert("必填项不能为空");  
	            return false;  
	        }
	        var elem = document.getElementById("name");  
	        if(!checkRequired(elem)){  
	            alert("必填项不能为空");  
	            return false;  
	        }
	    };
	};
	
	/**
	 * 该文件需要在平台文件引入之后引入
	 */
	window.CheckUtil={};
	CheckUtil.checkIsNull=function(id){
		var form=document.getElementById(id);
		return checkIsNull(form,true);
	};
	CheckUtil.checkedInit=function(){
		checkedInit();
	};
	CheckUtil.checkFormFormat=function(id){
		return checkFormFormat(id);
	};
	CheckUtil.formCheck=function(id){
		if(!this.checkIsNull(id)){
			alert("请填写必填项");
			return false;
		}
		if(!this.checkFormFormat(id)){
			alert("填写格式不正确");
			return false;
		}
		return true;
	};